package cn.yoegg.login;

import cn.yoegg.utils.MyApp;
import cn.yoegg.mzjw.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class SetNet extends Activity {

	private RadioGroup wGroup = null;
	private RadioButton servOneButton = null;
	private RadioButton servTwoButton = null;
	private RadioButton servThreeButton = null;
	private Button setBut;
	private String myUrl = "";
	//private String myUrl = "jw3.csmzxy.com";//

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setnet);

		wGroup = (RadioGroup) findViewById(R.id.netGroup);
		servOneButton = (RadioButton) findViewById(R.id.net2Button);;
		servTwoButton = (RadioButton) findViewById(R.id.net3Button);
		servThreeButton = (RadioButton) findViewById(R.id.net6Button);

		setBut = (Button) findViewById(R.id.setBut);
		setBut.setOnClickListener(setClick);
		
		//
		Toast.makeText(this, R.string.default_ip, Toast.LENGTH_SHORT).show();
		
		wGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if (servOneButton.getId() == checkedId) {
					myUrl = "jw2.csmzxy.com:8088";
					MyApp myApp = (MyApp) getApplication();
					myApp.setMyUrl(myUrl);
				} 
				if (servTwoButton.getId() == checkedId) {
					myUrl = "jw3.csmzxy.com:8088";
					MyApp myApp = (MyApp) getApplication();
					myApp.setMyUrl(myUrl);
					
				}
				else if (servThreeButton.getId() == checkedId) {
					myUrl = "jw6.csmzxy.com:8088";
					MyApp myApp = (MyApp) getApplication();
					myApp.setMyUrl(myUrl);
					
				};
			}
		});

	}

	OnClickListener setClick = new OnClickListener() {

		public void onClick(View v) {
			MyApp myApp = (MyApp) getApplication();
			myApp.setMyUrl(myUrl);
			SetNet.this.finish();
		}
	};
}